package com.example.demo.database.migration;

import com.example.demo.database.services.base.Migrator;
import com.example.demo.database.services.base.SqlCompiler;

public class UserMigrator extends Migrator {

    @Override
    public void up(SqlCompiler sqlCompiler) {
        sqlCompiler.create("users", columnGenerator -> {
            columnGenerator.id();
            columnGenerator.string("number").nullable().comment("学生：学号 老师：工号");
            columnGenerator.string("name").nullable().comment("姓名");
            columnGenerator.string("gender").nullable().comment("性别");
            columnGenerator.string("grade").nullable().comment("年级");
            columnGenerator.string("college").nullable().comment("学院");
            columnGenerator.string("major").nullable().comment("专业");
            columnGenerator.string("clazz").nullable().comment("班级");
            columnGenerator.timestamps();
            columnGenerator.softDeletes();
        });
        sqlCompiler.create("user_phones", columnGenerator -> {
            columnGenerator.id();
            columnGenerator.string("number").nullable().comment("学生：学号 老师：工号");
            columnGenerator.string("type").nullable().comment("类型");
            columnGenerator.integer("value").nullable().comment("号码");
            columnGenerator.timestamps();
            columnGenerator.softDeletes();
        });

    }

    @Override
    public void down(SqlCompiler sqlCompiler) {
        sqlCompiler.dropIfExists("users");
        sqlCompiler.dropIfExists("user_phones");
    }
}
